﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace calculator
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请依次输入算式的两个操作数和运算符：");
            double result = 0;      //计算结果
            double s1, s2;          //两个操作数
            char op;                //运算符
            
                s1 = Convert.ToDouble(Console.ReadLine());
                s2 = Convert.ToDouble(Console.ReadLine());
Tag:                op = Convert.ToChar(Console.ReadLine());
                switch (op)
                {
                    case '+':
                        result = s1 + s2; break;
                    case '-':
                        result = s1 - s2; break;
                    case '*':
                        result = s1 * s2; break;
                    case '/':
                        if (s1 == 0)
                        {
                            Console.WriteLine("被除数不得为0,请重新输入被除数");
                        result = Convert.ToDouble(Console.ReadLine())/s2;
                        break;
                        }
                        else result = s1 / s2;
                        break;
                    default:
                        {
                            Console.WriteLine("运算符输入有误，请重新输入运算符");
                        goto Tag;
                        }
                }
            Console.Write("计算结果为" + result);
        }
    }
}
